<template>
  <div>
    <a-input disabled v-model="curValue" placeholder="客户选择" style="width:85%"> </a-input>
    <a-button
      :disabled="disabled"
      @click="handleOpenChoose"
      slot="suffix"
      style="width:15%"
      class="searchBtn"
      type="primary"
    >
      <a-icon class="colour" type="search" />
    </a-button>
    <UserCloosee ref="supplierChoose" @onChoose="handleChoose"></UserCloosee>
  </div>
</template>
<script>
import UserCloosee from './UserCloose'

export default {
  props: {
    value: { type: [String, Object], required: false },
    disabled: { type: Boolean, required: false, default: false }
  },
  components: {
    UserCloosee
  },
  data() {
    return {
      curValue: '',
      keyword: '',
      RealName: '',
      timeout: null,
      dataSource: []
    }
  },
  watch: {
    value(value) {
      this.curValue = value
      //console.log(value)
      if (this.dataSource.length === 0) {
        if (value) {
          this.dataSource = [...value]
        } else {
          this.dataSource = []
          //console.log(this.dataSource, value, '错误')
        }
      }
    },
    curValue(n, o) {
      //console.log(n, o)
      if (n) {
        //console.log(this.$parent)
      }
    }
  },
  mounted() {
    this.curValue = this.value
  },
  methods: {
    changeuser() {
      //console.log(124)
    },
    handleSearch(value) {
      this.reload(value)
      //console.log(123)
    },
    handleOpenChoose() {
      this.$refs.supplierChoose.openChoose()
    },
    handleChoose(selectedRows) {
      // this.$emit('onname', this.RealName)
      this.dataSource = [...selectedRows]
      var row = selectedRows[0]
      this.curValue = row.cCusName
      this.$emit('input', this.curValue)
      this.$emit('OnCusName', row)
    }
  }
}
</script>

<style>
.searchBtn {
  vertical-align: baseline;
}
.colour {
  color: #fff;
}
</style>
